﻿using Microsoft.EntityFrameworkCore;
using TodoList.Data;

namespace TodoList.MinimalApi.Endpoints.TodoList;

public class GetList : IEndpoint
{
	public void MapEndpoint(IEndpointRouteBuilder endpoints)
	{
		endpoints.MapGet("/api/todolist", async (ApplicationDbContext db) =>
		{
			var result = await db.TodoItems.ToListAsync();
			return Results.Ok(result);
		})
		.WithName("GetTodoList")
		.WithTags(Tags.TodoList);
	}
}
